/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import components.ClosingTab;
import components.ConnectServer;
import components.Toolbar;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.net.Socket;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * Main class
 */
public class ProjectClient extends JFrame {

    private Socket socket;
    private ClosingTab tabbedPane;
    /**
     * Constructor
     */
    public ProjectClient() {
        ConnectServer cs = new ConnectServer(socket);
        if(cs.connect()){
            this.socket = cs.getSocket();
            initGUI();
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        ProjectClient client = new ProjectClient();
    }

    /**
     * Initialize GUI
     */
    private void initGUI() {
        this.setVisible(true);
        Toolkit t = Toolkit.getDefaultToolkit();
        Dimension d = t.getScreenSize();
        this.setSize(d.width, d.height - 50);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setTitle("Client");
        
        JPanel topPanel = new JPanel();
        topPanel.setLayout(new BorderLayout());
        this.getContentPane().add(topPanel);

        //add tab pane to top panel
        tabbedPane = new ClosingTab();
        topPanel.add(tabbedPane, BorderLayout.CENTER);
        
        //add toolbar to top panel
        Toolbar toolbar = new Toolbar(tabbedPane, socket);
        topPanel.add(toolbar, BorderLayout.WEST);
    }
}
